package com.spddr.pmos.jpa;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import cn.seqdata.jpa.AbstractPersistable;

@Entity
@Table(name = "trade_result")
public class TradeResult extends AbstractPersistable<TradeResultId> {
	private static final long serialVersionUID = 1L;

	private Trade trade;
	private Organization saler;
	private Organization buyer;
	private Double energy;
	private Double price;
	private Double fee;

	public TradeResult() {
	}

	public TradeResult(long trade, long buyer, long saler) {
		setId(new TradeResultId(trade, buyer, saler));
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "trade", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Trade getTrade() {
		return trade;
	}

	public void setTrade(Trade trade) {
		this.trade = trade;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "saler", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Organization getSaler() {
		return saler;
	}

	public void setSaler(Organization saler) {
		this.saler = saler;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "buyer", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Organization getBuyer() {
		return buyer;
	}

	public void setBuyer(Organization buyer) {
		this.buyer = buyer;
	}

	public Double getEnergy() {
		return energy;
	}

	public void setEnergy(Double energy) {
		this.energy = energy;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Double getFee() {
		return fee;
	}

	public void setFee(Double fee) {
		this.fee = fee;
	}
}